let array = [5, 3, 8, 4, 2];
const len = array.length;
for (let i = 0; i < len - 1; i++) {
    for (let j = 0; j < len - 1 - i; j++) {
    if (array[j] > array[j + 1]) {
    const temp = array[j];
    array[j] = array[j + 1];
    array[j + 1] = temp;
    }
    }
    }
    console.log(array)